<?php
/**
 * Description of sqlclass
 *
 * @author mavr
 */
class sqlclass{
    public $dbErr = false;
    
    function _construct() {
        controller::logLocal("грузим sqlclass");
        $conf = $this->configuredb();
        controller::logLocal('берем конфигурацию подключения к БД', $conf ? 'ок' : 'fail');
        include_once $_SERVER['DOCUMENT_ROOT'].'/db/mysql.php';
        controller::logLocal('инклудим mysql.php');
        $sql = new sql_db($conf->dbhost,$conf->dbuser,$conf->dbpasswd,$conf->dbmain);
        if (!$sql->db_connect_id) $this->dbErr = true;

        $sql->sql_query("set names utf8");
        return $sql;
    }

    function configuredb() {
        $file = $_SERVER['DOCUMENT_ROOT']."/conf/configDb.xml";
        $xmlfile = file_get_contents($file);
        $xml = new SimpleXMLElement($xmlfile);
        $output->dbhost = $xml->DataBaseConfig->host;
        $output->dbuser = $xml->DataBaseConfig->user;
        $output->dbpasswd = $xml->DataBaseConfig->passwd;
        $output->dbmain = $xml->DataBaseConfig->main;

        return $output;
    }

}
?>
